.permission-management {
  display: flex;
  flex-direction: column;
  padding: 16px;
  height: calc(100vh - 120px);
  gap: 16px;

  .header-card {
    flex-shrink: 0;
  }

  .main-content {
    flex: 1;
    overflow: hidden;
    min-height: 0;
  }

  .content-card {
    display: flex;
    flex-direction: column;
    height: 100%;

    :deep(.n-card__content) {
      display: flex;
      flex-direction: column;
      flex: 1;
      overflow: hidden;
    }
  }

  // 统计卡片样式
  .stat-grid {
    margin-bottom: 16px;
  }

  .stat-card-clickable {
    cursor: pointer;
    transition: all 0.3s ease;

    &:hover {
      transform: translateY(-4px);
      box-shadow: 0 8px 25px rgba(0, 0, 0, 0.15);
    }

    &.stat-card-active {
      border: 2px solid var(--n-primary-color);
      box-shadow: 0 4px 15px rgba(24, 144, 255, 0.2);
    }
  }

  .stat-icon {
    width: 48px;
    height: 48px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s ease;
  }

  .stat-content {
    .stat-label {
      font-size: 12px;
      color: var(--n-text-color-disabled);
      margin-bottom: 4px;
      font-weight: 500;
    }

    .stat-value {
      font-size: 24px;
      font-weight: bold;
      color: var(--n-text-color-base);
      line-height: 1;
    }
  }

  // 筛选标签样式
  .filter-tags {
    margin-bottom: 16px;
    padding: 12px;
    background: var(--n-color-base);
    border: 1px solid var(--n-border-color);
    border-radius: 6px;
  }

  // 表格容器样式
  .table-container {
    flex: 1;
    overflow: hidden;
    min-height: 0;

    :deep(.n-data-table-wrapper) {
      max-height: 400px;
      overflow: auto;
    }

    :deep(.n-data-table) {
      .n-data-table-tbody {
        max-height: 350px;
        overflow-y: auto;
      }
    }
  }

  // 统计卡片悬停效果
  :deep(.n-card) {
    transition: all 0.2s ease;
    
    &:hover {
      transform: translateY(-2px);
      box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
    }
  }

  // 搜索筛选栏样式
  .search-filters {
    :deep(.n-input) {
      .n-input__prefix {
        color: var(--n-text-color-disabled);
      }
    }
    
    :deep(.n-select) {
      .n-base-selection-placeholder {
        color: var(--n-text-color-disabled);
      }
    }
  }

  // 表格样式增强
  :deep(.n-data-table) {
    // 权限编码样式
    .permission-code {
      font-family: 'Monaco', 'Menlo', 'Ubuntu Mono', monospace;
      font-size: 12px;
      padding: 2px 6px;
      background: var(--n-color-base);
      border: 1px solid var(--n-border-color);
      border-radius: 3px;
      color: var(--n-primary-color);
    }

    // 权限类型标签样式
    .permission-type-tag {
      display: inline-flex;
      align-items: center;
      gap: 4px;
      
      .type-icon {
        opacity: 0.8;
      }
    }

    // 资源列表样式
    .resource-list {
      .resource-item {
        font-family: 'Monaco', 'Menlo', 'Ubuntu Mono', monospace;
        font-size: 11px;
        color: var(--n-text-color-disabled);
        line-height: 1.4;
        margin-bottom: 2px;
        
        &:last-child {
          margin-bottom: 0;
        }
      }
    }

    // 模块标签样式
    .module-tag {
      font-size: 12px;
      background: var(--n-info-color-suppl);
      color: var(--n-info-color);
      border: 1px solid var(--n-info-color-hover);
      border-radius: 4px;
      padding: 2px 8px;
    }

    // 表格行样式优化
    .n-data-table-tbody .n-data-table-tr {
      &:hover {
        background-color: var(--n-table-color-hover);
      }
    }

    // 表格头部样式
    .n-data-table-thead .n-data-table-th {
      background-color: var(--n-table-header-color);
      font-weight: 600;
      border-bottom: 2px solid var(--n-border-color);
    }
  }

  // 权限详情样式
  .permission-detail {
    .permission-help {
      margin-bottom: 16px;
      
      :deep(.n-alert) {
        border-radius: 8px;
        
        .n-alert__header {
          display: flex;
          align-items: center;
          gap: 8px;
          font-weight: 600;
        }
      }
    }

    .usage-guide {
      .guide-item {
        margin-bottom: 16px;
        padding: 12px;
        background: var(--n-color-base);
        border: 1px solid var(--n-border-color);
        border-radius: 6px;

        .guide-title {
          font-size: 13px;
          color: var(--n-text-color-base);
          margin-bottom: 8px;
          font-weight: 600;
        }

        .guide-content {
          font-size: 12px;
          color: var(--n-text-color-disabled);
          line-height: 1.5;
        }
      }
    }

    // 描述列表样式
    :deep(.n-descriptions) {
      .n-descriptions-item-label {
        font-weight: 500;
        color: var(--n-text-color-base);
        width: 100px;
      }
      
      .n-descriptions-item-content {
        color: var(--n-text-color-base);
      }
    }
  }

  // 表单样式增强
  :deep(.n-form) {
    .n-form-item {
      margin-bottom: 16px;
    }

    // 权限编码输入框
    .permission-code-input {
      .n-input__suffix {
        color: var(--n-text-color-disabled);
        
        .n-button {
          color: var(--n-primary-color);
          
          &:hover {
            color: var(--n-primary-color-hover);
            background: var(--n-primary-color-suppl);
          }
        }
      }
    }

    // 资源输入提示
    .resource-hint {
      font-size: 11px;
      color: var(--n-text-color-disabled);
      margin-top: 4px;
      font-style: italic;
    }

    // 表单项标签样式
    .n-form-item-label {
      font-weight: 500;
    }

    // 必填项标记样式
    .n-form-item-label--required::before {
      color: var(--n-error-color);
    }
  }

  // 操作按钮样式
  .action-buttons {
    .batch-action {
      :deep(.n-button) {
        &:disabled {
          opacity: 0.5;
          cursor: not-allowed;
        }
      }
    }
  }

  // 分页器样式
  :deep(.n-pagination) {
    justify-content: flex-end;
    
    .n-pagination-item {
      &.n-pagination-item--active {
        background: var(--n-primary-color);
        color: white;
      }
    }

    .n-pagination-quick-jumper {
      .n-input {
        width: 60px;
      }
    }
  }

  // 权限状态样式
  .permission-status {
    &.status-active {
      color: var(--n-success-color);
    }
    
    &.status-inactive {
      color: var(--n-error-color);
    }
  }

  // 权限编码复制功能
  .code-copy {
    position: relative;
    cursor: pointer;
    
    &:hover {
      background: var(--n-primary-color-suppl);
    }
    
    .copy-tooltip {
      position: absolute;
      top: -30px;
      left: 50%;
      transform: translateX(-50%);
      background: var(--n-color-base);
      border: 1px solid var(--n-border-color);
      border-radius: 4px;
      padding: 4px 8px;
      font-size: 12px;
      color: var(--n-text-color-base);
      white-space: nowrap;
      z-index: 10;
    }
  }

  // 权限等级指示器
  .permission-level {
    &.level-module {
      border-left: 4px solid var(--n-info-color);
      padding-left: 8px;
    }
    
    &.level-function {
      border-left: 4px solid var(--n-success-color);
      padding-left: 8px;
    }
    
    &.level-button {
      border-left: 4px solid var(--n-warning-color);
      padding-left: 8px;
    }
    
    &.level-api {
      border-left: 4px solid var(--n-error-color);
      padding-left: 8px;
    }
  }

  // 空状态样式
  .empty-state {
    padding: 60px 20px;
    text-align: center;
    
    .empty-icon {
      font-size: 48px;
      color: var(--n-text-color-disabled);
      margin-bottom: 16px;
    }
    
    .empty-text {
      color: var(--n-text-color-disabled);
      font-size: 14px;
    }
  }

  // 加载状态
  .loading-overlay {
    position: relative;
    
    &::after {
      content: '';
      position: absolute;
      top: 0;
      left: 0;
      right: 0;
      bottom: 0;
      background: rgba(255, 255, 255, 0.8);
      display: flex;
      align-items: center;
      justify-content: center;
      z-index: 10;
      border-radius: 6px;
    }
  }

  // 批量操作提示
  .batch-hint {
    background: var(--n-info-color-suppl);
    border: 1px solid var(--n-info-color);
    border-radius: 6px;
    padding: 8px 12px;
    margin-bottom: 16px;
    font-size: 12px;
    color: var(--n-info-color);
    
    .hint-icon {
      margin-right: 6px;
    }
  }

  // 模态框样式优化
  :deep(.n-dialog) {
    .n-dialog__title {
      font-weight: 600;
      color: var(--n-text-color-base);
    }

    .n-dialog__content {
      max-height: 70vh;
      overflow-y: auto;
    }
  }

  // 抽屉样式优化
  :deep(.n-drawer) {
    .n-drawer-header {
      border-bottom: 1px solid var(--n-border-color);
      padding-bottom: 12px;
      
      .n-drawer-header__main {
        font-weight: 600;
      }
    }

    .n-drawer-body {
      padding: 16px;
    }
  }

  // 标签样式增强
  :deep(.n-tag) {
    font-weight: 500;
    
    &.n-tag--info {
      background-color: var(--n-info-color-suppl);
      border-color: var(--n-info-color-hover);
    }

    &.n-tag--success {
      background-color: var(--n-success-color-suppl);
      border-color: var(--n-success-color-hover);
    }

    &.n-tag--warning {
      background-color: var(--n-warning-color-suppl);
      border-color: var(--n-warning-color-hover);
    }

    &.n-tag--error {
      background-color: var(--n-error-color-suppl);
      border-color: var(--n-error-color-hover);
    }
  }

  // 响应式设计
  @media (max-width: 1200px) {
    .stat-grid {
      :deep(.n-grid-item) {
        &:nth-child(n+3) {
          margin-top: 16px;
        }
      }
    }
  }

  @media (max-width: 768px) {
    padding: 8px;
    gap: 8px;
    
    .header-card {
      :deep(.n-space) {
        flex-direction: column;
        align-items: stretch;
        gap: 12px;
        
        .search-filters {
          :deep(.n-space) {
            flex-wrap: wrap;
            gap: 8px;
          }
          
          .n-input,
          .n-select {
            min-width: 150px;
            flex: 1;
          }
        }
      }
    }
    
    .stat-grid {
      :deep(.n-grid) {
        grid-template-columns: repeat(2, 1fr);
      }
    }
    
    :deep(.n-data-table) {
      font-size: 12px;
      
      .n-data-table-th,
      .n-data-table-td {
        padding: 8px 4px;
      }
    }

    // 移动端表格优化
    :deep(.n-data-table-wrapper) {
      overflow-x: auto;
    }

    // 移动端模态框优化
    :deep(.n-dialog) {
      width: 95% !important;
      max-width: 95% !important;
    }

    // 移动端抽屉优化
    :deep(.n-drawer) {
      width: 100% !important;
      max-width: 100% !important;
    }
  }

  @media (max-width: 480px) {
    padding: 4px;
    
    .stat-grid {
      :deep(.n-grid) {
        grid-template-columns: 1fr;
        gap: 8px;
      }
    }

    .stat-content {
      .stat-value {
        font-size: 20px;
      }
    }
  }

  // 暗色主题适配
  :deep(.n-config-provider[data-theme="dark"]) {
    .permission-code {
      background: rgba(255, 255, 255, 0.1);
      border-color: rgba(255, 255, 255, 0.2);
    }
    
    .stat-icon {
      background: rgba(255, 255, 255, 0.05);
    }

    .usage-guide {
      .guide-item {
        background-color: rgba(255, 255, 255, 0.05);
        border-color: rgba(255, 255, 255, 0.1);
      }
    }

    .loading-overlay {
      &::after {
        background: rgba(0, 0, 0, 0.8);
      }
    }
  }

  // 打印样式
  @media print {
    .header-card,
    .action-buttons,
    :deep(.n-pagination) {
      display: none;
    }

    .main-content {
      height: auto;
      overflow: visible;
    }

    :deep(.n-data-table) {
      font-size: 10px;
    }
  }

  // 动画效果
  .fade-enter-active,
  .fade-leave-active {
    transition: opacity 0.2s ease;
  }

  .fade-enter-from,
  .fade-leave-to {
    opacity: 0;
  }

  .slide-enter-active,
  .slide-leave-active {
    transition: transform 0.3s ease;
  }

  .slide-enter-from {
    transform: translateX(100%);
  }

  .slide-leave-to {
    transform: translateX(-100%);
  }

  // 无障碍支持
  :focus-visible {
    outline: 2px solid var(--n-primary-color);
    outline-offset: 2px;
  }

  // 高对比度模式支持
  @media (prefers-contrast: high) {
    :deep(.n-tag) {
      border-width: 2px;
    }

    .stat-icon {
      border: 2px solid currentColor;
    }
  }

  // 减少动画模式支持
  @media (prefers-reduced-motion: reduce) {
    * {
      animation-duration: 0.01ms !important;
      animation-iteration-count: 1 !important;
      transition-duration: 0.01ms !important;
    }
  }
}